<?php

namespace App\Providers;

use Illuminate\Support\Facades\Cache;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Validator::extend('yzmgz',function($attribute, $value, $parameters){
            $phone = session('phone');
            $code = cache('code'.$phone);
            return $value == $code;
        });
        Validator::extend('timeout',function($attribute, $value, $parameters){
            $phone = session('phone');
            if(Cache::has('code'.$phone)){
                return true;
            }else{
                return false;
            }
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
